﻿using NetEasyMusic.Lib.Models;
using Newtonsoft.Json.Linq;

namespace NetEasyMusic.Lib.Recommend;

public class DJRecommend
{
    public DJRecommend(JToken token)
    {
        Name = token["name"]?.ToObject<string>()!;
        Items = token["programs"]?.Select(x => new DJRecommendItem(x)).ToArray() ?? [];
    }

    public DJRecommendItem[] Items { get; set; }
    public string Name { get; set; }
}

public class DJRecommendItem : IRecommend
{
    public DJRecommendItem(JToken token)
    {
        Id = token["id"]?.ToObject<string>()!;
        Name = token["name"]?.ToObject<string>()!;
        PicUrl = token["coverUrl"]?.ToObject<string>()!;
        DjNickname = token["dj"]?["nickname"]?.ToObject<string>()!;
        DjSignature = token["dj"]?["signature"]?.ToObject<string>()!;
        DjAvatarUrl = token["dj"]?["avatarUrl"]?.ToObject<string>()!;
        Brand = token["dj"]?["brand"]?.ToObject<string>()!;
        RadioId = token["radio"]?["id"]?.ToObject<string>()!;
        RadioName = token["radio"]?["name"]?.ToObject<string>()!;
        RadioPicUrl = token["radio"]?["picUrl"]?.ToObject<string>()!;
        RadioDesc = token["radio"]?["desc"]?.ToObject<string>()!;
        Channels = token["channels"]?.ToObject<string[]>()!;
        Description = token["description"]?.ToObject<string>()!;
        Artists = token["mainSong"]?["artists"]?.Select(x => new ArtistModel(x)).ToArray() ?? [];
        Album = token["mainSong"]?["album"]?["name"]?.ToObject<string>()!;
        AlbumId = token["mainSong"]?["album"]?["id"]?.ToObject<string>()!;
    }

    public string Name { get; set; }
    public string Id { get; set; }
    public string Description { get; set; }
    public string[] Channels { get; set; }
    public ArtistModel[] Artists { get; set; }
    public string Album { get; set; }
    public string AlbumId { get; set; }
    public string DjNickname { get; set; }
    public string DjSignature { get; set; }
    public string DjAvatarUrl { get; set; }
    public string Brand { get; set; }
    public string RadioId { get; set; }
    public string RadioName { get; set; }
    public string RadioPicUrl { get; set; }
    public string RadioDesc { get; set; }
    public string PicUrl { get; set; }
}